home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / midi / gfft.lha / gfft-2.03 / source / gfft-2.03-source.lha / wbcopyrt.c < prev    next >
C/C++ Source or Header  |  1996-01-02  |  7KB  |  269 lines

  1. /***************************************************************************
  2.  *          Copyright (C) 1994  Charles P. Peterson                  *
  3.  *         4007 Enchanted Sun, San Antonio, Texas 78244-1254             *
  4.  *              Email: Charles_P_Peterson@fcircus.sat.tx.us                *
  5.  *                                                                         *
  6.  *          This is free software with NO WARRANTY.                  *
  7.  *          See gfft.c, or run program itself, for details.              *
  8.  *              Support is available for a fee.                      *
  9.  ***************************************************************************
  10.  *
  11.  * Program:     gfft--General FFT analysis
  12.  * File:        wbcopyrt.c
  13.  * Purpose:     copyright dialog requester
  14.  * Author:      Charles Peterson (CPP)
  15.  * History:     11-Feb-1994 CPP; Created.
  16.  *              10-Jul-1994 CPP (0.76); Fixed "fast click" bug
  17.  *              14-Dec-94 CPP (1.17); Fix button gadgets for >4 colors
  18.  * Comments:    Workbench GUI.  Amiga Dependent!
  19.  */
  20.  
  21. #ifdef AMIGA  /* This module is AMIGA dependent */
  22.  
  23. #include <stdio.h>     /* sprintf() */
  24. #include <string.h>
  25.  
  26. /*
  27.  * Amiga includes
  28.  */
  29. #include <exec/types.h>
  30. #include <workbench/workbench.h>
  31. #include <intuition/intuition.h>
  32. #include <clib/intuition_protos.h>
  33. #include <clib/exec_protos.h>
  34. #include <dos.h> /* chkabort() */
  35.  
  36. /*
  37.  * GFFT includes
  38.  */
  39. #include "gfft.h"
  40. #include "settings.h"  /* for testing */
  41. #include "wbench.h"
  42.  
  43. /*
  44.  * External globals
  45.  */
  46. extern struct Window *dialog_window_p;
  47. extern char *Author_Strings[];
  48. extern short Max_Columns;
  49. extern char *Copyrt_Req_Prolog;
  50. extern char *Author_Info_Button;
  51. extern char *No_Warranty_Button;
  52. extern char *Sharing_Rights_Button;
  53. extern char *Idea_Contributor_Button;
  54. extern char *Code_Contributor_Button;
  55.  
  56. #define FIRST_AUTHOR_LINE 1  /* Line 0 is blank */
  57.  
  58. static struct Requester *copyright_rp = NULL;
  59. static struct Requester *author_rp = NULL;
  60.  
  61. static struct Gadget *author_gadgetp;
  62. static struct Gadget *copying_gadgetp, *nowarranty_gadgetp;
  63. static struct Gadget *idea_contributor_gadgetp, *code_contributor_gadgetp;
  64. static struct Gadget *financial_contributor_gadgetp;
  65. static struct Gadget *end_copyright_gadgetp, *ok_author_gadgetp;
  66.  
  67. #define MAX_AUTHOR_LINES 7
  68.  
  69. static struct IntuiText *prolog_textp;
  70. static struct IntuiText *author_textp[MAX_AUTHOR_LINES];
  71. static struct Gadget *next_author_gadgetp;
  72. static struct Gadget *previous_author_gadgetp;
  73.  
  74. static void author (int start_line);
  75.  
  76. void copyright_requester (void)
  77. {
  78.     struct IntuiMessage *message;
  79.     APTR *address = NULL;
  80.     ULONG class = 0;
  81.  
  82.     if (!copyright_rp)
  83.     {
  84.     gadget__begin (GTYP_REQGADGET);
  85. /*
  86.  * Setup Text
  87.  */
  88.     prolog_textp = requester_text__new (Copyrt_Req_Prolog, 0, 0);
  89.  
  90. /*
  91.  * Setup Gadgets
  92.  */
  93.     author_gadgetp = action_button__new (Author_Info_Button, 0, 1);
  94.  
  95.     nowarranty_gadgetp = action_button__new (No_Warranty_Button, 0, 2);
  96.  
  97.     copying_gadgetp = action_button__new (Sharing_Rights_Button, 0, 3);
  98.  
  99.     idea_contributor_gadgetp = action_button__new 
  100.       (Idea_Contributor_Button, 0, 4);
  101.  
  102.     code_contributor_gadgetp = action_button__new
  103.       (Code_Contributor_Button, 0, 5);
  104.  
  105. /*
  106.  *    financial_contributor_gadgetp = action_button__new
  107.  *      ("Financial support has been contributed by...",
  108.  *       0, 6);
  109.  */
  110.  
  111.     end_copyright_gadgetp = tall_action_button__new
  112.       ("...OK", Max_Columns - 5, 7);
  113.  
  114.     copyright_rp = requester__new ();
  115.     copyright_rp->ReqGadget = end_copyright_gadgetp;
  116.     copyright_rp->ReqText = prolog_textp;
  117.  
  118.     } /* Ok, copyright_rp has been created */
  119.     
  120.     if (requester__display (copyright_rp, dialog_window_p))
  121.     {
  122.     while (TRUE)
  123.     {
  124.         Wait (1 << dialog_window_p->UserPort->mp_SigBit);
  125.         while (message = (struct IntuiMessage *) GetMsg 
  126.            (dialog_window_p->UserPort))
  127.         {
  128.         CATCH_ERROR
  129.         class = message->Class;
  130.         address = message->IAddress;
  131.         ReplyMsg ((struct Message *) message);
  132.         if (address == (APTR) author_gadgetp)
  133.         {
  134.             author (FIRST_AUTHOR_LINE);
  135.         }
  136.         else if (address == (APTR) copying_gadgetp)
  137.         {
  138.             copying_message (NullString);
  139.         }
  140.         else if (address == (APTR) nowarranty_gadgetp)
  141.         {
  142.             no_warranty_message (NullString);
  143.         }
  144.         else if (address == (APTR) idea_contributor_gadgetp)
  145.         {
  146.             help_message ("idea contributors");
  147.         }
  148.         else if (address == (APTR) code_contributor_gadgetp)
  149.         {
  150.             help_message ("code contributors");
  151.         }
  152.         else if (address == (APTR) financial_contributor_gadgetp)
  153.         {
  154.             help_message ("financial contributors");
  155.         }
  156.         else if (address == (APTR) end_copyright_gadgetp)
  157.         {
  158.             requester__remove (copyright_rp, dialog_window_p);
  159.             return;
  160.         }
  161.         END_CATCH_ERROR
  162.         }
  163.     }
  164.     }
  165. }
  166.  
  167. static void author (int start_line)
  168. {
  169.     struct IntuiMessage *message;
  170.     APTR *address = NULL;
  171.     ULONG class = 0;
  172.     static int author_line_count = 0;
  173.     int start_line_here = start_line;
  174.     int end_line_here;
  175.     int line_count_here;
  176.     int i, j;
  177.     int col;
  178.     static BOOLEAN all_pages_seen = FALSE;
  179.  
  180.     if (!author_line_count)
  181.     {
  182.     while (Author_Strings[author_line_count++]);
  183.     }
  184.     if (author_rp)
  185.     {
  186.     gfree (author_rp);  /* should free text also... */
  187.     author_rp = NULL;
  188.     }
  189.  
  190.     while (Author_Strings[start_line_here] && 
  191.        strlen (Author_Strings[start_line_here++]) <= 1);
  192.     end_line_here = --start_line_here;
  193.  
  194.     while (Author_Strings[end_line_here])
  195.     {
  196.     col = strlen (Author_Strings[end_line_here]);
  197.     if (col <= 1) break;
  198.     end_line_here++;
  199.     }
  200.     end_line_here--;
  201.  
  202.     line_count_here = 1 + end_line_here - start_line_here;
  203.     if (line_count_here < 1 || line_count_here > MAX_AUTHOR_LINES) return;
  204.  
  205.     gadget__begin (GTYP_REQGADGET);
  206.  
  207.     for (i = start_line_here, j = 0; i <= end_line_here; i++, j++)
  208.     {
  209.     author_textp[j] = requester_text__new (Author_Strings[i], 0, j);
  210.     }
  211.  
  212.     next_author_gadgetp = action_button__new ("Next", 11, j);
  213.     if (end_line_here + 3 >= author_line_count)
  214.     {
  215.     next_author_gadgetp->Flags |= GFLG_DISABLED;
  216.     all_pages_seen = TRUE;
  217.     }
  218.  
  219.     previous_author_gadgetp = action_button__new ("Previous", 0, j);
  220.     if (start_line_here <= FIRST_AUTHOR_LINE || !all_pages_seen)
  221.       previous_author_gadgetp->Flags |= GFLG_DISABLED;
  222.  
  223.     ok_author_gadgetp = action_button__new ("...OK", Max_Columns - 5, j);
  224.     if (!all_pages_seen)
  225.       ok_author_gadgetp->Flags |= GFLG_DISABLED;
  226.  
  227.     author_rp = requester__new ();
  228.     author_rp->ReqGadget = ok_author_gadgetp;
  229.     author_rp->ReqText = author_textp[j-1];
  230.  
  231.     if (requester__display (author_rp, dialog_window_p))
  232.     {
  233.     while (TRUE)
  234.     {
  235.         Wait (1 << dialog_window_p->UserPort->mp_SigBit);
  236.         while (message = (struct IntuiMessage *) GetMsg 
  237.            (dialog_window_p->UserPort))
  238.         {
  239.         class = message->Class;
  240.         address = message->IAddress;
  241.         ReplyMsg ((struct Message *) message);
  242.         if (address == (APTR) ok_author_gadgetp)
  243.         {
  244.             requester__remove (author_rp, dialog_window_p);
  245.             return;
  246.         }
  247.         else if (address == (APTR) next_author_gadgetp)
  248.         {
  249.             requester__remove (author_rp, dialog_window_p);
  250.             author (end_line_here + 2);
  251.             return;
  252.         }
  253.         else if (address == (APTR) previous_author_gadgetp)
  254.         {
  255.             i = start_line_here - 1;
  256.             if (i-1 < FIRST_AUTHOR_LINE) break;
  257.             while (Author_Strings[i] &&
  258.                (strlen (Author_Strings[--i]) > 1));
  259.             requester__remove (author_rp, dialog_window_p);
  260.             author (i);
  261.             return;
  262.         }
  263.         }
  264.     }
  265.     }
  266. }
  267.  
  268. #endif /* end ifdef AMIGA */
  269.